import { createBrowserRouter ,Navigate } from "react-router-dom"
import Home from "../pages/home"
import Login from "../pages/login"
import ErrorPages from "@/pages/404/index"
import ArticleManage from "@/pages/home/components/main/ArticleManage"
import AuthorityManage from "@/pages/home/components/main/AuthorityManage"
const routes = [
  {
    path:'/',
    element:<Navigate to={'/login'} replace/>
  },
  {
    element:<Login/>,
    path:'login'
  },
  {
    element:<Home/>,
    path:'/home',
    children:[
      // 子路由不加横杆
      // 子路由重定向方案
      {
        path:'/home',
        element:<Navigate to={'/home/articleManage'} replace/>
      },
      {
        path:'articleManage',
        element:<ArticleManage/>
      },
      {
        path:'authorityManage',
        element:<AuthorityManage/>
      },
    ]
  },
  // 404路由拦截放到最下面自动匹配,优先匹配上述所有路由
  {
    element:<ErrorPages/>,
    path:'*'
  }
]
 
export default createBrowserRouter(routes)